using System;
using System.Collections.Generic;
using System.Text;

namespace Nihonaid.classes.scheduler
{
    /// <summary>
    /// Implements the Sebastian Leitner's scheduling system
    /// </summary>
    class LeitnerScheduler : IScheduler
    {
        private List<int> number_days;

        /// <summary>
        /// Constructs the scheduler
        /// </summary>
        public LeitnerScheduler()
        {
            this.number_days = new List<int>();
            LoadSchedulerData();
        }

        /// <summary>
        /// Loads the scheduler data
        /// </summary>
        public void LoadSchedulerData()
        {
            number_days.Add(0); // unused
            number_days.Add(7); // 7 days
            number_days.Add(12); // 12 days 
            number_days.Add(20); // 20 days
            number_days.Add(30); // 30 days
            number_days.Add(60); // 60 days
            number_days.Add(90); // 90 days
            number_days.Add(30 * 5); // 5 months
            number_days.Add(30 * 9); // 9 months
            number_days.Add(30 * 16); // 16 months
            number_days.Add(30 * 12 * 2); // 2 years
            number_days.Add(30 * 12 * 4); // 4 years
            number_days.Add(30 * 12 * 6); // 6 years
            number_days.Add(30 * 12 * 11); // 11 years
        }

        /// <summary>
        /// Returns the next scheduled repetition date
        /// </summary>
        /// <param name="number_successful_repetitions">Number of successful repetitions in a row</param>
        /// <returns>Next repetition date</returns>
        public DateTime GetNextDate(int number_successful_repetitions)
        {
            DateTime now = DateTime.Now;
            now = now.AddDays((double)number_days[number_successful_repetitions]);
            return now;
        }
    }
}